{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import glob\n",
    "import os\n",
    "import gc\n",
    "import json \n",
    "base_path = '../input/indoor-location-navigation/'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# pull out all the buildings actually used in the test set, given current method we don't need the other ones\n",
    "ssubm = pd.read_csv('../input/indoor-location-navigation/sample_submission.csv')\n",
    "\n",
    "# only 24 of the total buildings are used in the test set, \n",
    "# this allows us to greatly reduce the intial size of the dataset\n",
    "\n",
    "ssubm_df = ssubm[\"site_path_timestamp\"].apply(lambda x: pd.Series(x.split(\"_\")))\n",
    "used_buildings = sorted(ssubm_df[0].value_counts().index.tolist())\n",
    "\n",
    "# dictionary used to map the floor codes to the values used in the submission file. \n",
    "floor_map = {\"B2\":-2, \"B1\":-1, \"F1\":0, \"F2\": 1, \"F3\":2, \"F4\":3, \"F5\":4, \"F6\":5, \"F7\":6,\"F8\":7, \"F9\":8,\n",
    "             \"1F\":0, \"2F\":1, \"3F\":2, \"4F\":3, \"5F\":4, \"6F\":5, \"7F\":6, \"8F\": 7, \"9F\":8}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# # get only the wifi bssid that occur over 1000 times(this number can be experimented with)\n",
    "# # these will be the only ones used when constructing features\n",
    "# bssid = dict()\n",
    "\n",
    "# for building in used_buildings:\n",
    "# #     break\n",
    "#     folders = sorted(glob.glob(os.path.join(base_path,'train/'+building+'/*')))\n",
    "#     print(building)\n",
    "#     wifi = list()\n",
    "#     for folder in folders:\n",
    "#         floor = floor_map[folder.split('/')[-1]]\n",
    "#         files = glob.glob(os.path.join(folder, \"*.txt\"))\n",
    "#         for file in files:\n",
    "#             with open(file) as f:\n",
    "#                 txt = f.readlines()\n",
    "#                 for e, line in enumerate(txt):\n",
    "#                     tmp = line.strip().split()\n",
    "#                     if tmp[1] == \"TYPE_WIFI\":\n",
    "#                         wifi.append(tmp)\n",
    "#     df = pd.DataFrame(wifi)\n",
    "#     #top_bssid = df[3].value_counts().iloc[:500].index.tolist()\n",
    "#     value_counts = df[3].value_counts()\n",
    "#     top_bssid = value_counts[value_counts >= 0].index.tolist()\n",
    "#     print(len(top_bssid))\n",
    "#     bssid[building] = top_bssid\n",
    "#     del df\n",
    "#     del wifi\n",
    "#     gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# with open(\"bssid.json\", \"w\") as f:\n",
    "#     json.dump(bssid, f)\n",
    "\n",
    "with open(\"bssid.json\") as f:\n",
    "    bssid = json.load(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import re\n",
    "def multi_line_spliter(s):\n",
    "    matches = re.finditer(\"TYPE_\", s)\n",
    "    matches_positions = [match.start() for match in matches]\n",
    "    split_idx = [0] + [matches_positions[i]-14 for i in range(1, len(matches_positions))] + [len(s)]\n",
    "    return [s[split_idx[i]:split_idx[i+1]] for i in range(len(split_idx)-1)]\n",
    "    \n",
    "    \n",
    "def load_df(file):\n",
    "    #path = str(Path(self.input_path)/f\"train/{self.site_id}/{self.floor}/{self.path_id}.txt\")\n",
    "    with open(file) as f:\n",
    "        data = f.readlines()\n",
    "\n",
    "#     modified_data = []\n",
    "#     for s in data:\n",
    "#         if s.count(\"TYPE_\")>1:\n",
    "#             lines = multi_line_spliter(s)\n",
    "#             modified_data.extend(lines)\n",
    "#         else:\n",
    "#             modified_data.append(s)\n",
    "#     del data\n",
    "#     return modified_data\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "from dataclasses import dataclass\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "\n",
    "@dataclass\n",
    "class ReadData:\n",
    "    acce: np.ndarray\n",
    "    acce_uncali: np.ndarray\n",
    "    gyro: np.ndarray\n",
    "    gyro_uncali: np.ndarray\n",
    "    magn: np.ndarray\n",
    "    magn_uncali: np.ndarray\n",
    "    ahrs: np.ndarray\n",
    "    wifi: np.ndarray\n",
    "    ibeacon: np.ndarray\n",
    "    waypoint: np.ndarray\n",
    "\n",
    "\n",
    "def read_data_file(data_filename):\n",
    "    acce = []\n",
    "    acce_uncali = []\n",
    "    gyro = []\n",
    "    gyro_uncali = []\n",
    "    magn = []\n",
    "    magn_uncali = []\n",
    "    ahrs = []\n",
    "    wifi = []\n",
    "    ibeacon = []\n",
    "    waypoint = []\n",
    "\n",
    "    with open(data_filename, 'r', encoding='utf-8') as file:\n",
    "        lines = file.readlines()\n",
    "\n",
    "    for line_data in lines:\n",
    "        line_data = line_data.strip()\n",
    "        if not line_data or line_data[0] == '#':\n",
    "            continue\n",
    "\n",
    "        line_data = line_data.split('\\t')\n",
    "\n",
    "        if line_data[1] == 'TYPE_ACCELEROMETER':\n",
    "            acce.append([int(line_data[0]), float(line_data[2]), float(line_data[3]), float(line_data[4])])\n",
    "            continue\n",
    "\n",
    "        if line_data[1] == 'TYPE_ACCELEROMETER_UNCALIBRATED':\n",
    "            acce_uncali.append([int(line_data[0]), float(line_data[2]), float(line_data[3]), float(line_data[4])])\n",
    "            continue\n",
    "\n",
    "        if line_data[1] == 'TYPE_GYROSCOPE':\n",
    "            gyro.append([int(line_data[0]), float(line_data[2]), float(line_data[3]), float(line_data[4])])\n",
    "            continue\n",
    "\n",
    "        if line_data[1] == 'TYPE_GYROSCOPE_UNCALIBRATED':\n",
    "            gyro_uncali.append([int(line_data[0]), float(line_data[2]), float(line_data[3]), float(line_data[4])])\n",
    "            continue\n",
    "\n",
    "        if line_data[1] == 'TYPE_MAGNETIC_FIELD':\n",
    "            magn.append([int(line_data[0]), float(line_data[2]), float(line_data[3]), float(line_data[4])])\n",
    "            continue\n",
    "\n",
    "        if line_data[1] == 'TYPE_MAGNETIC_FIELD_UNCALIBRATED':\n",
    "            magn_uncali.append([int(line_data[0]), float(line_data[2]), float(line_data[3]), float(line_data[4])])\n",
    "            continue\n",
    "\n",
    "        if line_data[1] == 'TYPE_ROTATION_VECTOR':\n",
    "            ahrs.append([int(line_data[0]), float(line_data[2]), float(line_data[3]), float(line_data[4])])\n",
    "            continue\n",
    "\n",
    "        if line_data[1] == 'TYPE_WIFI':\n",
    "            sys_ts = line_data[0]\n",
    "            ssid = line_data[2]\n",
    "            bssid = line_data[3]\n",
    "            rssi = line_data[4]\n",
    "            lastseen_ts = line_data[6]\n",
    "            wifi_data = [sys_ts, ssid, bssid, rssi, lastseen_ts]\n",
    "            wifi.append(wifi_data)\n",
    "            continue\n",
    "\n",
    "        if line_data[1] == 'TYPE_BEACON':\n",
    "            ts = line_data[0]\n",
    "            uuid = line_data[2]\n",
    "            major = line_data[3]\n",
    "            minor = line_data[4]\n",
    "            rssi = line_data[6]\n",
    "            ibeacon_data = [ts, '_'.join([uuid, major, minor]), rssi]\n",
    "            ibeacon.append(ibeacon_data)\n",
    "            continue\n",
    "\n",
    "        if line_data[1] == 'TYPE_WAYPOINT':\n",
    "            waypoint.append([int(line_data[0]), float(line_data[2]), float(line_data[3])])\n",
    "\n",
    "    acce = np.array(acce)\n",
    "    acce_uncali = np.array(acce_uncali)\n",
    "    gyro = np.array(gyro)\n",
    "    gyro_uncali = np.array(gyro_uncali)\n",
    "    magn = np.array(magn)\n",
    "    magn_uncali = np.array(magn_uncali)\n",
    "    ahrs = np.array(ahrs)\n",
    "    wifi = np.array(wifi)\n",
    "    ibeacon = np.array(ibeacon)\n",
    "    waypoint = np.array(waypoint)\n",
    "\n",
    "    return ReadData(acce, acce_uncali, gyro, gyro_uncali, magn, magn_uncali, ahrs, wifi, ibeacon, waypoint)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5a0546857ecc773753327266\n",
      "-1\n",
      "0\n",
      "1\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-6-74e73dc9d7ca>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m     14\u001b[0m         \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfloor\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     15\u001b[0m         \u001b[0;32mfor\u001b[0m \u001b[0mfile\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mfiles\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 16\u001b[0;31m             \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mread_data_file\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfile\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     17\u001b[0m             \u001b[0;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwifi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m>\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     18\u001b[0m                 \u001b[0mwifi_data\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDataFrame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwifi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m<ipython-input-5-26abf575fd1a>\u001b[0m in \u001b[0;36mread_data_file\u001b[0;34m(data_filename)\u001b[0m\n\u001b[1;32m     53\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     54\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mline_data\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m'TYPE_GYROSCOPE_UNCALIBRATED'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 55\u001b[0;31m             \u001b[0mgyro_uncali\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline_data\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfloat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline_data\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfloat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline_data\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfloat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline_data\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     56\u001b[0m             \u001b[0;32mcontinue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     57\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "# generate all the training data \n",
    "# used_buildings[:1]\n",
    "for building in used_buildings:\n",
    "    #break\n",
    "    folders = sorted(glob.glob(os.path.join(base_path,'train', building +'/*')))\n",
    "    dfs = list()\n",
    "    index = sorted(bssid[building])\n",
    "    print(building)\n",
    "    building_df_wifi = []\n",
    "    building_df_waypoint = []\n",
    "    for folder in folders:\n",
    "        floor = floor_map[folder.split('/')[-1]]\n",
    "        files = glob.glob(os.path.join(folder, \"*.txt\"))\n",
    "        print(floor)\n",
    "        for file in files:\n",
    "            data = read_data_file(file)\n",
    "            if len(data.wifi)>0:\n",
    "                wifi_data = pd.DataFrame(data.wifi)\n",
    "                wifi_data.columns = ['ts_wifi','ssid','bssid','rssi','ts_wifi_ls']\n",
    "                wifi_data['path'] = file.split('/')[-1].split('.')[0]\n",
    "                wifi_data['site'] = file.split('/')[-3]\n",
    "                wifi_data['floor'] = floor\n",
    "                wifi_data['floor_ori'] = folder.split('/')[-1]\n",
    "                building_df_wifi.append(wifi_data) \n",
    "            if len(data.waypoint)>0:\n",
    "                waypoint_data = pd.DataFrame(data.waypoint)\n",
    "                waypoint_data.columns = ['ts_waypoint','x','y']\n",
    "                waypoint_data['path'] = file.split('/')[-1].split('.')[0]\n",
    "                waypoint_data['site'] = file.split('/')[-3]\n",
    "                waypoint_data['floor'] = floor\n",
    "                waypoint_data['floor_ori'] = folder.split('/')[-1]\n",
    "                building_df_waypoint.append(waypoint_data)             \n",
    "    building_df_wifi = pd.concat(building_df_wifi).reset_index(drop=True)\n",
    "    building_df_waypoint = pd.concat(building_df_waypoint).reset_index(drop=True)\n",
    "    building_df_wifi.to_csv('../input/data_abstract/'+building+\"_train_wifi.csv\")\n",
    "    building_df_waypoint.to_csv('../input/data_abstract/'+building+\"_train_waypoint.csv\")\n",
    "    \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5a0546857ecc773753327266</td>\n",
       "      <td>046cfa46be49fc10834815c6</td>\n",
       "      <td>0000000000009</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5a0546857ecc773753327266</td>\n",
       "      <td>046cfa46be49fc10834815c6</td>\n",
       "      <td>0000000009017</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                          0                         1              2\n",
       "0  5a0546857ecc773753327266  046cfa46be49fc10834815c6  0000000000009\n",
       "1  5a0546857ecc773753327266  046cfa46be49fc10834815c6  0000000009017"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ssubm_df.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5a0546857ecc773753327266\n",
      "5c3c44b80379370013e0fd2b\n",
      "5d27075f03f801723c2e360f\n",
      "5d27096c03f801723c31e5e0\n",
      "5d27097f03f801723c320d97\n",
      "5d27099f03f801723c32511d\n",
      "5d2709a003f801723c3251bf\n",
      "5d2709b303f801723c327472\n",
      "5d2709bb03f801723c32852c\n",
      "5d2709c303f801723c3299ee\n",
      "5d2709d403f801723c32bd39\n",
      "5d2709e003f801723c32d896\n",
      "5da138274db8ce0c98bbd3d2\n",
      "5da1382d4db8ce0c98bbe92e\n",
      "5da138314db8ce0c98bbf3a0\n",
      "5da138364db8ce0c98bc00f1\n",
      "5da1383b4db8ce0c98bc11ab\n",
      "5da138754db8ce0c98bca82f\n",
      "5da138764db8ce0c98bcaa46\n",
      "5da1389e4db8ce0c98bd0547\n",
      "5da138b74db8ce0c98bd4774\n",
      "5da958dd46f8266d0737457b\n",
      "5dbc1d84c1eb61796cf7c010\n",
      "5dc8cea7659e181adb076a3f\n"
     ]
    }
   ],
   "source": [
    "ssubm_building_g = ssubm_df.groupby(0)\n",
    "feature_dict = dict()\n",
    "\n",
    "for gid0, g0 in ssubm_building_g:\n",
    "    index = sorted(bssid[g0.iloc[0,0]])\n",
    "    feats = list()\n",
    "    print(gid0)\n",
    "    building_df_wifi = []\n",
    "    for gid,g in g0.groupby(1):\n",
    "\n",
    "        # get all wifi time locations\n",
    "        #with open(os.path.join(base_path, 'test/' + g.iloc[0,1] + '.txt')) as f:\n",
    "            #txt = f.readlines()\n",
    "        data = read_data_file(os.path.join(base_path, 'test/' + g.iloc[0,1] + '.txt'))\n",
    "        if len(data.wifi)>0:\n",
    "            wifi_data = pd.DataFrame(data.wifi)\n",
    "            wifi_data.columns = ['ts_wifi','ssid','bssid','rssi','ts_wifi_ls']\n",
    "            wifi_data['path'] = g.iloc[0,1]\n",
    "            wifi_data['site'] = gid0\n",
    "            building_df_wifi.append(wifi_data)            \n",
    "    building_df_wifi = pd.concat(building_df_wifi).reset_index(drop=True)\n",
    "    building_df_wifi.to_csv('../input/data_abstract/'+gid0+\"_test_wifi.csv\")\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ts_wifi</th>\n",
       "      <th>ssid</th>\n",
       "      <th>bssid</th>\n",
       "      <th>rssi</th>\n",
       "      <th>ts_wifi_ls</th>\n",
       "      <th>path</th>\n",
       "      <th>site</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0000000002340</td>\n",
       "      <td>da39a3ee5e6b4b0d3255bfef95601890afd80709</td>\n",
       "      <td>eebf5db207eec2f3e041f92153d789270f346821</td>\n",
       "      <td>-45</td>\n",
       "      <td>1578474544726</td>\n",
       "      <td>046cfa46be49fc10834815c6</td>\n",
       "      <td>5a0546857ecc773753327266</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0000000002340</td>\n",
       "      <td>b9f0208be00bd8b337be7f12e02e3a3ce846e22b</td>\n",
       "      <td>7805f319f3f591986effe78c5b41143180278f2d</td>\n",
       "      <td>-46</td>\n",
       "      <td>1578474565732</td>\n",
       "      <td>046cfa46be49fc10834815c6</td>\n",
       "      <td>5a0546857ecc773753327266</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0000000002340</td>\n",
       "      <td>ab150ecf6d972b476aeab16317bed6189d9f7cce</td>\n",
       "      <td>323607d8444900d64151ee06d164738ac727bbce</td>\n",
       "      <td>-46</td>\n",
       "      <td>1578474564279</td>\n",
       "      <td>046cfa46be49fc10834815c6</td>\n",
       "      <td>5a0546857ecc773753327266</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0000000002340</td>\n",
       "      <td>b6ffe5619e02871fcd04f61c9bb4b5c53a3f46b7</td>\n",
       "      <td>b26914599f6d9ba16b43975394e1eeb9d82f4bab</td>\n",
       "      <td>-47</td>\n",
       "      <td>1578474565725</td>\n",
       "      <td>046cfa46be49fc10834815c6</td>\n",
       "      <td>5a0546857ecc773753327266</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0000000002340</td>\n",
       "      <td>da39a3ee5e6b4b0d3255bfef95601890afd80709</td>\n",
       "      <td>02a1be3a5dab38320f879489d8a1e0f2a72768b3</td>\n",
       "      <td>-47</td>\n",
       "      <td>1578474547962</td>\n",
       "      <td>046cfa46be49fc10834815c6</td>\n",
       "      <td>5a0546857ecc773753327266</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>338901</th>\n",
       "      <td>0000000067545</td>\n",
       "      <td>b6ffe5619e02871fcd04f61c9bb4b5c53a3f46b7</td>\n",
       "      <td>f2fd7c8b3ae74a54ebcd5498b81b513b7c5e564a</td>\n",
       "      <td>-90</td>\n",
       "      <td>1578465380606</td>\n",
       "      <td>ffcd9524c80c0fa5bb859eaf</td>\n",
       "      <td>5a0546857ecc773753327266</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>338902</th>\n",
       "      <td>0000000067545</td>\n",
       "      <td>b9f0208be00bd8b337be7f12e02e3a3ce846e22b</td>\n",
       "      <td>94887049b5d6072ffd22a5e7de70523931861c2b</td>\n",
       "      <td>-91</td>\n",
       "      <td>1578465380654</td>\n",
       "      <td>ffcd9524c80c0fa5bb859eaf</td>\n",
       "      <td>5a0546857ecc773753327266</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>338903</th>\n",
       "      <td>0000000067545</td>\n",
       "      <td>b7e6027447eb1f81327d66cfd3adbe557aabf26c</td>\n",
       "      <td>e9f5c01efe9058d460ed3830b2a23b729dea930a</td>\n",
       "      <td>-92</td>\n",
       "      <td>1578465380607</td>\n",
       "      <td>ffcd9524c80c0fa5bb859eaf</td>\n",
       "      <td>5a0546857ecc773753327266</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>338904</th>\n",
       "      <td>0000000067545</td>\n",
       "      <td>02eb66d35bce69814f108c2f876e600a78ace137</td>\n",
       "      <td>0f5daed11a61e0d6941a1a42ff428ca216d61003</td>\n",
       "      <td>-93</td>\n",
       "      <td>1578465370203</td>\n",
       "      <td>ffcd9524c80c0fa5bb859eaf</td>\n",
       "      <td>5a0546857ecc773753327266</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>338905</th>\n",
       "      <td>0000000067545</td>\n",
       "      <td>d4f84491d3a4cd7fbd6f2e34e35fc3cf2f9c5c56</td>\n",
       "      <td>bfaebb72653fac35c19b00e7ce484dc2897f18bd</td>\n",
       "      <td>-93</td>\n",
       "      <td>1578465377777</td>\n",
       "      <td>ffcd9524c80c0fa5bb859eaf</td>\n",
       "      <td>5a0546857ecc773753327266</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>338906 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              ts_wifi                                      ssid  \\\n",
       "0       0000000002340  da39a3ee5e6b4b0d3255bfef95601890afd80709   \n",
       "1       0000000002340  b9f0208be00bd8b337be7f12e02e3a3ce846e22b   \n",
       "2       0000000002340  ab150ecf6d972b476aeab16317bed6189d9f7cce   \n",
       "3       0000000002340  b6ffe5619e02871fcd04f61c9bb4b5c53a3f46b7   \n",
       "4       0000000002340  da39a3ee5e6b4b0d3255bfef95601890afd80709   \n",
       "...               ...                                       ...   \n",
       "338901  0000000067545  b6ffe5619e02871fcd04f61c9bb4b5c53a3f46b7   \n",
       "338902  0000000067545  b9f0208be00bd8b337be7f12e02e3a3ce846e22b   \n",
       "338903  0000000067545  b7e6027447eb1f81327d66cfd3adbe557aabf26c   \n",
       "338904  0000000067545  02eb66d35bce69814f108c2f876e600a78ace137   \n",
       "338905  0000000067545  d4f84491d3a4cd7fbd6f2e34e35fc3cf2f9c5c56   \n",
       "\n",
       "                                           bssid rssi     ts_wifi_ls  \\\n",
       "0       eebf5db207eec2f3e041f92153d789270f346821  -45  1578474544726   \n",
       "1       7805f319f3f591986effe78c5b41143180278f2d  -46  1578474565732   \n",
       "2       323607d8444900d64151ee06d164738ac727bbce  -46  1578474564279   \n",
       "3       b26914599f6d9ba16b43975394e1eeb9d82f4bab  -47  1578474565725   \n",
       "4       02a1be3a5dab38320f879489d8a1e0f2a72768b3  -47  1578474547962   \n",
       "...                                          ...  ...            ...   \n",
       "338901  f2fd7c8b3ae74a54ebcd5498b81b513b7c5e564a  -90  1578465380606   \n",
       "338902  94887049b5d6072ffd22a5e7de70523931861c2b  -91  1578465380654   \n",
       "338903  e9f5c01efe9058d460ed3830b2a23b729dea930a  -92  1578465380607   \n",
       "338904  0f5daed11a61e0d6941a1a42ff428ca216d61003  -93  1578465370203   \n",
       "338905  bfaebb72653fac35c19b00e7ce484dc2897f18bd  -93  1578465377777   \n",
       "\n",
       "                            path                      site  \n",
       "0       046cfa46be49fc10834815c6  5a0546857ecc773753327266  \n",
       "1       046cfa46be49fc10834815c6  5a0546857ecc773753327266  \n",
       "2       046cfa46be49fc10834815c6  5a0546857ecc773753327266  \n",
       "3       046cfa46be49fc10834815c6  5a0546857ecc773753327266  \n",
       "4       046cfa46be49fc10834815c6  5a0546857ecc773753327266  \n",
       "...                          ...                       ...  \n",
       "338901  ffcd9524c80c0fa5bb859eaf  5a0546857ecc773753327266  \n",
       "338902  ffcd9524c80c0fa5bb859eaf  5a0546857ecc773753327266  \n",
       "338903  ffcd9524c80c0fa5bb859eaf  5a0546857ecc773753327266  \n",
       "338904  ffcd9524c80c0fa5bb859eaf  5a0546857ecc773753327266  \n",
       "338905  ffcd9524c80c0fa5bb859eaf  5a0546857ecc773753327266  \n",
       "\n",
       "[338906 rows x 7 columns]"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "building_df_wifi"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
